'use strict';
const fs = require('fs');
const os = require('os');

const LogWriter = require('./log_writer');

/**
 * FileLogWriter - write log to file
 */
class FileLogWriter extends LogWriter {
  constructor(filePath) {
    super();
    this.filePath = filePath;
  }
  write(data, clear = false) {
    fs.writeFileSync(this.filePath, data + os.EOL, { flag: clear ? 'w' : 'a' });
  }
}

module.exports = FileLogWriter;
